#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTableView>
#include <QTableWidget>
#include <QSqlQueryModel>
#include <QHBoxLayout>
#include <QSystemTrayIcon>
#include <QCloseEvent>
#include <QDataWidgetMapper>
#include <QSqlTableModel>

#include "newcustomerdialog.h"
#include "despositdialog.h"
#include "drawdialog.h"
#include "unlockdialog.h"
#include "logindialog.h"
#include "querydialog.h"



namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
     bool showLogin();
     void setUser(QString userName);
     void setPassword(QString userPassword);
     void showTrayIcon();


signals:
    void sendPassword(QString password);

protected:
     void closeEvent(QCloseEvent *event);

private:
     void createTrayIcon();
     void queryByUserName(QString userName);
     void queryByProductName(QString productName);
     void queryByPrice(float price);
     void queryByDate(QString date);
     void queryBalance(int column,QString data);
     void queryDesposit(int column,QString data);
     void queryDraw(int column,QString data);



private slots:
    void actionNewCustomer();
    void actionDesposit();
    void actionDraw();
    void about();
    void aboutQt();
    void balanceStatistics();
    void despositStatistics();
    void drawStatistics();
    void userQuery(QString sql);
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
    void exportExcelFile();
    void lockApp();
    void unlockApp();
    void getUser(QString user,QString password);
    void test(QModelIndex index);
    void slotQuery();
    void slotEdit();
    void slotDelete();

private:
    Ui::MainWindow *ui;
    newCustomerDialog *newCustomer;
    despositDialog *desposit;
    drawDialog *draw;
    QTableView *view;
    QSqlTableModel *tableModel;
    QSqlQueryModel *model;
    QSystemTrayIcon *trayIcon;
    QMenu *trayIconMenu;
    QAction *deleteItem;
    QAction *exportExcel;
    QAction *lock;
    QAction *unlock;
    QAction *editItem;
    bool isLock;
    unlockDialog *passwordDialog;
    QString user;
    QString password;
    loginDialog *login;
    queryDialog *dialogQuery;
    int kindOfQuery;
    QDataWidgetMapper *mapper;
    bool isEdit;

};

#endif // MAINWINDOW_H
